﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Global.asax.cs" company="Home">
//   2014
// </copyright>
// <summary>
//   Defines the MvcApplication type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace NinjectWithMVC
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Http;
    using System.Web.Mvc;
    using System.Web.Optimization;
    using System.Web.Routing;

    using Ninject;
    using Ninject.Modules;
    using Ninject.Web.Common;

    using NinjectWithMVC.DI;

    /// <summary>
    /// The MVC application.
    /// </summary>
    public class MvcApplication : NinjectHttpApplication
    {
        /// <summary>
        /// The on application started.
        /// </summary>
        protected override void OnApplicationStarted()
        {
            base.OnApplicationStarted();
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }

        /// <summary>
        /// The create kernel.
        /// </summary>
        /// <returns>
        /// The <see cref="IKernel"/>.
        /// </returns>
        protected override Ninject.IKernel CreateKernel()
        {
            return new StandardKernel(new INinjectModule[] { new DefaultDIModule() });
        }
    }
}